package com.cloud.bc.controller.ajax;

import com.cloud.bc.model.entity.BcCategoryDistricts;
import com.cloud.bc.model.response.AjaxResp;
import com.cloud.bc.service.BcCategoryDistrictsService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 下拉
 */
@AllArgsConstructor
@RestController
@RequestMapping("ajax/select")
public class Ajax_SelectController {
    private final BcCategoryDistrictsService bcCategoryDistrictsService;

    //获取省市区
    @GetMapping("categoryDistricts/{parentId}")
    public AjaxResp categoryDistricts(@PathVariable("parentId") Integer parentId) {
        AjaxResp ajaxResp = new AjaxResp();
        BcCategoryDistricts bcCategoryDistricts = new BcCategoryDistricts();
        bcCategoryDistricts.setParentId(parentId);
        List<BcCategoryDistricts> bcCategoryDistrictsResult = bcCategoryDistrictsService.selectAll(bcCategoryDistricts);
        ajaxResp.setList(bcCategoryDistrictsResult);
        return ajaxResp;
    }
}
